package com.wuzuqing.android.eightdiagrams

import android.graphics.Color
import android.widget.TextView
import com.wuzuqing.android.eightdiagrams.base.BaseAdapter
import com.wuzuqing.android.eightdiagrams.base.BaseViewHolder
import com.wuzuqing.android.eightdiagrams.model.QiMenDunJiaItem
import com.wuzuqing.android.eightdiagrams.model.QiMenDunJiaModel
import com.wuzuqing.android.eightdiagrams.utils.DataUtils

/**
 * @CopyRight: 广州仰望星空云科技有限公司
 * @Author : wuzuqing
 * @Email:wuzuqing@xinyu668.com
 * @CreateTime: 26.7.24 10:12 AM
 * @Description: 请写描述
 */
class QiMenDunJiaAdapter(
    var menBaGua: QiMenDunJiaModel? = null,
    var isShowOrigin: Boolean = false
) :
    BaseAdapter<QiMenDunJiaItem>(R.layout.item_qimendunjia) {

    var normalColor:Int = Color.parseColor("#333333")
    var poGongColor:Int = Color.parseColor("#FF613F")
    var ruMuColor:Int = Color.parseColor("#1CD83F")
    var xingColor:Int = Color.parseColor("#FF61D5")
    fun changeShowState(flag: Boolean) {
        if (isShowOrigin == flag) {
            return
        }
        isShowOrigin = flag
        notifyDataSetChanged()
    }

    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        getItem(position)?.also {
            holder.setText(R.id.tv_shen, it.shen)
            if (isShowOrigin) {
                holder.setText(
                    R.id.tv_men,
                    "${it.originMen}\n${it.men}${DataUtils.getMenBall(it.men)}"
                )
                holder.setText(
                    R.id.tv_xing,
                    "${it.originXing}\n${it.xing}${DataUtils.getJiuXingBall(it.xing)}"
                )
            } else {
                holder.setText(R.id.tv_men, "${it.men}${DataUtils.getMenBall(it.men)}")
                holder.setText(R.id.tv_xing, "${it.xing}${DataUtils.getJiuXingBall(it.xing)}")
            }

            if (it.isPoGong){
                holder.getView<TextView>(R.id.tv_men).setTextColor(poGongColor)
            }else{
                holder.getView<TextView>(R.id.tv_men).setTextColor(normalColor)
            }

            holder.setText(R.id.tv_dipangan, "${it.diPanGan}${it.diPanCangGan}")
            holder.setText(R.id.tv_tianpangan, it.tianPanGan)

            holder.setText(R.id.tv_gua_shu, it.flagStr)
            holder.setText(R.id.tv_gua, "${it.gua}${it.gongNum}\n${it.diPanZhi}")

        }
    }
}